package com.handpay.nocardpay.baselibrary.pay.unipay.presenter;
import android.content.Context;

import com.handpay.nocardpay.baselibrary.commbase.model.IBaseModel;
import com.handpay.nocardpay.baselibrary.commbase.model.bean.BaseErrorInfo;
import com.handpay.nocardpay.baselibrary.pay.unipay.model.MerchantTypeListModelImpl;
import com.handpay.nocardpay.baselibrary.pay.unipay.model.bean.MerchantTypeListBean;
import com.handpay.nocardpay.baselibrary.pay.unipay.view.IMerchantTypeListView;
import java.util.HashMap;

/**
 * Created by lyang on 2017/9/13.
 */

public class MerchantTypeListPresenter  implements IBaseModel.OnRequestFinishedListener<MerchantTypeListBean> {
    private MerchantTypeListModelImpl mMerchantTypeListModelImpl;
    private IMerchantTypeListView mMerchantTypeListView;

    public MerchantTypeListPresenter(Context context, IMerchantTypeListView view) {
        this.mMerchantTypeListModelImpl = new MerchantTypeListModelImpl(context);
        this.mMerchantTypeListView = view;
    }

    public void getMerchantTypeList(HashMap<String, Object> paramers, Class<MerchantTypeListBean> clzz, boolean isShowLoading) {
        if (mMerchantTypeListView != null) {
            if (isShowLoading) {
                mMerchantTypeListView.showProgress();
            }
        }
        mMerchantTypeListModelImpl.request(paramers, clzz, this);
    }

    @Override
    public void onError(BaseErrorInfo baseErrorInfo) {
        if (mMerchantTypeListView != null) {
            mMerchantTypeListView.hideProgress();
        }
    }

    @Override
    public void onSuccess(MerchantTypeListBean response) {
        if (mMerchantTypeListView != null) {
            mMerchantTypeListView.hideProgress();
            mMerchantTypeListView.queryMerchantTypeSuccess(response);
        }

    }
}
